// service/LoginResult.java
package service.Login;

public class LoginResult {
    public enum Status {
        SUCCESS, INVALID_CREDENTIALS, PERMISSION_DENIED, ERROR
    }

    private final Status status;
    private final String errorMessage;
    private final int userPermission;

    public LoginResult(Status status, String errorMessage, int userPermission) {
        this.status = status;
        this.errorMessage = errorMessage;
        this.userPermission = userPermission;
    }

    public static LoginResult success(int permission) {
        return new LoginResult(Status.SUCCESS, null, permission);
    }

    public static LoginResult invalidCredentials() {
        return new LoginResult(
                Status.INVALID_CREDENTIALS,
                "用户名或密码错误",
                -1
        );
    }

    public static LoginResult permissionDenied(String message) {
        return new LoginResult(
                Status.PERMISSION_DENIED,
                message != null ? message : "权限不足",
                -1
        );
    }

    public static LoginResult error(String message) {
        return new LoginResult(
                Status.ERROR,
                message != null ? message : "系统错误",
                -1
        );
    }

    // Getters
    public Status getStatus() { return status; }
    public String getErrorMessage() { return errorMessage; }
    public int getUserPermission() { return userPermission; }
}
